package jdbc;

import util.DBUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author oldliu
 * @since 1.0
 */
public class FindTotal {
    public static void main(String[] args) {
        Connection con= DBUtil.getConnection();
        PreparedStatement ps=null;
        ResultSet resultSet=null;
        try {
            ps=con.prepareStatement("select count(*) from s_student");
             resultSet = ps.executeQuery();
            if(resultSet.next()){
                int total=resultSet.getInt(1);
                System.out.println("学生总数是"+total);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            DBUtil.close(resultSet,ps,con);
        }

    }
}
